package com.jsh.erp.datasource.mappers;

import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.vo.Replenishment;
import javafx.geometry.Pos;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Description
 *
 * @Author: cjl
 * @Date: 2019/1/22 14:54
 */
public interface MaterialMapperEx {

    List<MaterialVo4Unit> selectByConditionMaterial(
            @Param("materialParam") String materialParam,
            @Param("color") String color,
            @Param("weight") String weight,
            @Param("expiryNum") String expiryNum,
            @Param("enableSerialNumber") String enableSerialNumber,
            @Param("enableBatchNumber") String enableBatchNumber,
            @Param("enabled") String enabled,
            @Param("remark") String remark,
            @Param("idList") List<String> idList,
            @Param("mpList") String mpList,
            @Param("offset") Integer offset,
            @Param("rows") Integer rows,
            @Param("name")String name,
            @Param("standard")String standard,
            @Param("model")String model,
            @Param("barCode")String barCode);

    Long countsByMaterial(
            @Param("materialParam") String materialParam,
            @Param("color") String color,
            @Param("weight") String weight,
            @Param("expiryNum") String expiryNum,
            @Param("enableSerialNumber") String enableSerialNumber,
            @Param("enableBatchNumber") String enableBatchNumber,
            @Param("enabled") String enabled,
            @Param("remark") String remark,
            @Param("idList") List<String> idList,
            @Param("mpList") String mpList,
            @Param("name")String name,
            @Param("standard")String standard,
            @Param("model")String model,
            @Param("barCode")String barCode);

    Long insertSelectiveEx(Material record);

    List<Unit> findUnitList(@Param("mId") String mId);

    List<MaterialVo4Unit> findById(@Param("id") String id);

    List<MaterialVo4Unit> findByIdWithMeId(@Param("meId") String meId);

    List<MaterialVo4Unit> findBySelectWithBarCode(@Param("idList") List<String> idList,
                                                  @Param("q") String q,
                                                  @Param("enableSerialNumber") String enableSerialNumber,
                                                  @Param("enableBatchNumber") String enableBatchNumber,
                                                  @Param("offset") Integer offset,
                                                  @Param("rows") Integer rows,
                                                  @Param("organId") String organId,
                                                  @Param("color") String color);

    int findBySelectWithBarCodeCount(@Param("idList") List<String> idList,
                                     @Param("q") String q,
                                     @Param("enableSerialNumber") String enableSerialNumber,
                                     @Param("enableBatchNumber") String enableBatchNumber,
                                     @Param("organId") String organId,
                                     @Param("color") String color);

    List<MaterialVo4Unit> exportExcel(
            @Param("name") String name,
            @Param("barCode") String barCode,
            @Param("standard") String standard,
            @Param("model") String model,
            @Param("color") String color,
            @Param("expiryNum") String expiryNum,
            @Param("enabled") String enabled,
            @Param("enableSerialNumber") String enableSerialNumber,
            @Param("enableBatchNumber") String enableBatchNumber,
            @Param("remark") String remark,
            @Param("idList") List<String> idList,
            @Param("materialList") List<String> materialList);
    /**
     * 通过商品名称查询商品信息
     * */
    List<Material> findByMaterialName(@Param("name") String name);
    /**
     * 获取开启序列号并且状态正常的商品列表
     * */
    List<MaterialVo4Unit> getMaterialEnableSerialNumberList(@Param("q") String q,
                                                     @Param("offset") Integer offset,
                                                     @Param("rows") Integer rows);

    String getMaterialEnableSerialNumberCount(@Param("q") String q);

    int batchDeleteMaterialByIds(@Param("updateTime") Date updateTime, @Param("updater") String updater, @Param("ids") String ids[]);

    List<Material> getMaterialListByCategoryIds(@Param("categoryIds") String[] categoryIds);

    List<Material> getMaterialListByUnitIds(@Param("unitIds") String[] unitIds);

    String getMaxBarCode();

    List<MaterialVo4Unit> getMaterialByMeId(
            @Param("meId") String meId);

    List<String> getMaterialNameList();

    int setUnitIdToNull(@Param("id") String id);

    int setExpiryNumToNull(@Param("id") String id);

    List<MaterialVo4Unit> getMaterialByMeIdList(@Param("meIdArray") String [] meIdArray);

//    List<MaterialVo4Unit> getMaterialByMaterialId(@Param("materialIdList") List<String> materialIdList,@Param("type") Integer type);

    List<MaterialVo4Unit> getMaterialByMaterialId(@Param("materialIdList") List<String> materialIdList,@Param("unitFlag") String unitFlag);

    List<String> getExtendByMaterialId(@Param("materialIdList") List<String> materialIdList,@Param("type") Integer type);


    MaterialVo4Unit getMByMeId(@Param("meId") String meId);


    List<MaterialInitialStockWithMaterial> getInitialStockWithMaterial(
            @Param("depotList") List<String> depotList);



    int checkIsExist(
            @Param("id") String id,
            @Param("name") String name,
            @Param("model") String model,
            @Param("color") String color,
            @Param("standard") String standard,
            @Param("mfrs") String mfrs,
            @Param("otherField1") String otherField1,
            @Param("otherField2") String otherField2,
            @Param("otherField3") String otherField3,
            @Param("unit") String unit,
            @Param("unitId") String unitId);

    int checkMaterialNameIsExist(@Param("name") String name);

    String getOrganIdByMaterialId(@Param("id") String id);

    MaterialVo4Unit getMaterialInfoByBarCode(@Param("barCode") String barCode);

    MaterialVo4Unit getMaterialInfoByMaterialNameWithUnit(@Param("materialName") String materialName,
                                                          @Param("categoryId") String categoryId,
                                                          @Param("unit") String unit,
                                                          @Param("standard") String standard,
                                                          @Param("color") String color,
                                                          @Param("barCode") String barCode);

    List<String> getMaterialIdList();

    int insertSelective(Material record);

    int insertList(@Param("list")List<Material> list);

    int updateByPrimaryKeySelective(Material record);

    List<PosMaterialVo> posMaterialList();
    List<PosMaterialVo> posSaleMaterialList();

    List<SingleItemInventoryVo> singleItemInventory(@Param("code") String code);

    List<BalanceMaterialVo> balanceMaterialList(@Param("pricing_method") String pricing_method,@Param("keyword") String keyword,@Param("person1") String person1,@Param("person2") String person2,@Param("person3") String person3,@Param("page") Integer page,@Param("limit") Integer limit);

    List<Map<String, Object>> goodsSort(@Param("id")String id);

    String selectMinimumUnit(String color);

    int findMaterialBySyncTenantId(@Param("id") String id,@Param("syncTenantId") String syncTenantId);

}
